#pragma once

#include <QWidget>
#include <QMutex>
#include <future>
#include "ui_SetupPagesContainer.h"
#include "../../SetupPageInterface.h"
#include "../../stdafx.h"

inline QString tstringToQString(const tstring& str) {
	QString strResult;
#if (defined _UNICODE || defined UNICODE)
	strResult = QString::fromStdWString(str);
#else
	strResult = QString::fromStdString(str);
#endif
	return strResult;
}

inline tstring QStringTotstring(const QString& str) {
#if (defined _UNICODE || defined UNICODE)
	return str.toStdWString();
#else
	return str.toStdString();
#endif
}

class SetupPagesContainer : public QWidget, public SetupPageInterface
{
	Q_OBJECT

public:
	SetupPagesContainer(QWidget *parent = nullptr);
	~SetupPagesContainer();
	void paintEvent(QPaintEvent *event) override;
	void mousePressEvent(QMouseEvent* event) override;
	void mouseMoveEvent(QMouseEvent* event) override;

	// SetupPluginInterface
	void SetTitle(const tstring& title) override;
	void SetRequiredSpaceKb(long kb) override;
	void SetInstallDirectory(const tstring& dir) override;
	tstring GetInstallDirectory() override;
	void SetInstallStepDescription(const tstring& description, int progressValue = -1) override;
	void NsisExtractFilesFinished() override;
	bool IsCreateDesktopShortcutEnabled() override;
	bool IsAutoStartupOnBootEnabled() override;
	void OutputDebugInfo(const tstring& logString) override;
private:
	void updateDriverInfo();
	void exitSetup();
	void loadStyleSheetFile(const QString& sheetName);

private:
	Ui::SetupPagesContainerClass ui;
	QPoint _dragPosition;
	bool _canDrag = false;
	long m_requiredSpaceKb;
	std::future<void> m_addListItemAsync;
	QMutex m_waitingAddItemsMutex;
	QStringList m_waitingAddItems;
};
